package com.woniuxy01;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;

/**
 * @author 作者
 * @create 2025-07-30 9:26
 */
public class Test01 {
    public static void main(String[] args) {
        String dateStr1 = "2017-03-01 22:33:23";
        Date date1 = DateUtil.parse(dateStr1);

        String dateStr2 = "2017-04-01 23:33:23";
        Date date2 = DateUtil.parse(dateStr2);

//相差一个月，31天
        long betweenDay = DateUtil.between(date1, date2, DateUnit.DAY);
        System.out.println(betweenDay);
    }

    private static void test02() {
        LocalDate localDate = LocalDate.of(2004,3,1);
        LocalDate date = localDate.plusDays(-1);
        System.out.println(date.getDayOfMonth());
    }

    private static void test01() {
        //xxxx-3-1  -1   二月的最后一天
        Calendar calendar = Calendar.getInstance();
        for (int year=2000;year<=2025;year++) {
            calendar.set(year, 2,1);
            calendar.add(Calendar.DATE, -1);
            System.out.println(calendar.get(Calendar.DATE));
        }
    }
}
